package router

import (
	"admin-nexus-backend/internal/handler"
	"admin-nexus-backend/internal/middleware"

	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
)

// SetupOrganizationRoutes 设置组织管理路由
func SetupOrganizationRoutes(router *gin.RouterGroup, db *gorm.DB, dataPermissionMiddleware *middleware.DataPermissionMiddleware) {
	organizationHandler := handler.NewOrganizationHandler(db)

	organizations := router.Group("/organizations")
	organizations.Use(dataPermissionMiddleware.DataPermission()) // 应用数据权限中间件
	{
		organizations.GET("", organizationHandler.GetOrganizationList)       // 获取组织列表
		organizations.GET("/:id", organizationHandler.GetOrganizationByID)   // 获取组织详情
		organizations.POST("", organizationHandler.CreateOrganization)       // 创建组织
		organizations.PUT("/:id", organizationHandler.UpdateOrganization)    // 更新组织
		organizations.DELETE("/:id", organizationHandler.DeleteOrganization) // 删除组织
		organizations.GET("/tree", organizationHandler.GetOrganizationTree)  // 获取组织树
	}
}
